﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YiYiTong.Rocket.Helper
{
    public static class SortedDictionaryExtension
    {
        public static object GetValue(this SortedDictionary<string, object> sd, string key)
        {
            object retValue;
            if (sd.TryGetValue(key.ToLower(), out retValue))
                return retValue;
            return null;
        }

        public static TValue GetValue<TValue>(this SortedDictionary<string, object> sd, string key, TValue defaultValue = default(TValue))
        {
            var sdValue = sd.GetValue(key);

            var retValue = ConvertHelper.ConvertTo<TValue>(sdValue, defaultValue);

            return retValue;
        }
    }
}
